﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body onload="OnLoad()">
    <table border="0" cellspacing="0" cellpadding="0" width="100%">
        <tr>
            <td>
                <object id="DVRPlayer" classid="CLSID:023D5C5C-2FFE-4054-8CE9-45C492778C52" width="600" height="450">
                </object>
            </td>
            <td>
                <div id="divPanel" style="visibility:hidden">
                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
                    	<tr>
                    		<td>IP:</td><td><input id="txtIP" type="text" /></td>
                            <td>Port:</td><td><input id="txtPort" type="text" /></td>
                            <td><input id="login" onclick="Login('super','uptfp','192.168.99.34','20000')" type="button" value="登录" /></td>
                            <td><input id="logout" onclick="Logout()" type="button" value="登出" /></td>
                    	</tr>
                        <tr>
                           <td><input id="startMonitor" onclick="StartMonitor(4)" type="button" value="启动监视" /></td> 
                           <td><input id="stopMonitor" onclick="StopMonitor()" type="button" value="停止监控" /></td>
                        </tr>
                        <tr>
                            <td><input id="setWndChannel" onclick="SetWndChannel(0,2)" type="button" value="切换通道" /></td>
                        </tr>
                        <tr>
                            <td><input id="capPic" onclick="CapPic()" type="button" value="截图" /></td>
                            <td><input id="openFile" onclick="OnOpenFile()" type="button" value="播放文件" /></td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td></td>
        </tr>
    </table>
    <div>
        <input id="fileMedia" type="file" onchange="OnOpenFile(this.value)"/>
        <button id="btnSHPanel" onclick="OnShowHidePanel()">显示/隐藏</button>
    </div>
    <script language="javascript" type="text/javascript" for="DVRPlayer" event="DBLCLICK">
            MouseDoubleClick();
    </script>
    <script language="javascript" type="text/javascript">
        function OnLoad() {
            //DVRPlayer.SetRenderWindowSize(352, 288);
            DVRPlayer.SetCapturePath("C:");

            var loginFlag = Login('super', 'uptfp', '192.168.99.34', '20000');
            StartMonitor(1);
            //ShowMetaData(true);

        }

        function OnShowHidePanel() {
            if (divPanel.style.visibility != "visible") {
                divPanel.style.visibility = "visible";
            }
            else {
                divPanel.style.visibility = "hidden";
            }
        }

        function OnOpenFile(filePath) {
            if (filePath != null && filePath.length > 0) {
                DVRPlayer.OpenFile(filePath);
           }
           else
           {
                alert("filePath != null");
           }
         }

         function Login(userName, passWord, severIP, severPort) {
             if ((userName != null && userName.length > 0) &&
                    (passWord != null && passWord.length) > 0 &&
                    (severIP != null && severIP.length > 0) &&
                    (severPort != null && severPort.length > 0)) {
                 return DVRPlayer.Login(userName, passWord, severIP, severPort);
            }
            else
            {
                alert("请检查登录信息！");
            }
        }

        function Logout() {
            DVRPlayer.Logout();
        }

        function StartMonitor(wndNum) {
            if (wndNum > 0) {
                DVRPlayer.StartMonitor(wndNum);
            }
            else 
            {
                alert("请输入分割线数！");
            }
        }

        function StopMonitor() {
            DVRPlayer.StopMonitor();
        }

        function SetWndChannel(lWndIndex, lChannelIndex) {
            if (lWndIndex >= 0 && lChannelIndex >= 0) {
                DVRPlayer.SetWndChannel(lWndIndex, lChannelIndex);
            }
            else {
                alert("========>>>Channel"); 
            }

        }

        function CapPic() {
            DVRPlayer.SetCapturePath("C:");
            DVRPlayer.CapPic();
        }

        function GetCapturePath() {
            DVRPlayer.GetCapturePath();
        }

        function ShowMetaData(bShow) {
            DVRPlayer.ShowMetaData(bShow);
        }

         function MouseDoubleClick() {
            //                DVRPlayer.style.left = 0;
            //                DVRPlayer.style.top = 0;
            //                DVRPlayer.width = screen.width;
            //                DVRPlayer.height = screen.height;
            //alert("mouse double click");
            //windowopen();
        }

        //            function toFull() {
        //                if (window.name == "fullscreen ") return;
        //                var a = window.open(" ", "fullscreen ", "fullscreen=yes ")
        //                a.location = window.location.href
        //                window.opener = null
        //                window.close()
        //            }

        //            function windowopen() {
        //                var target = "http://www.google.com";
        //                newwindow = window.open("", "", "scrollbars");
        //                if (document.all) {
        //                    newwindow.moveTo(0, 0)
        //                    newwindow.resizeTo(screen.width, screen.height)
        //                }
        //                newwindow.location = target
        //            }

    </script>
</body>
</html>
